﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PBO.Network.Domain
{
    public class UserInfo : DataByteArray
    {
        public byte position { get; set; }
        public string identity { get; set; }
        public List<byte> team { get; set; }

        public override void Read(NetworkLib.Utilities.ByteArray byteArray)
        {
            this.position = byteArray.ReadByte();
            this.identity = byteArray.ReadUTF();
            this.team = DataByteArray.ReadList<byte>(byteArray, b => b.ReadByte());
        }

        public override void Write(NetworkLib.Utilities.ByteArray byteArray)
        {
            byteArray.WriteByte(this.position);
            byteArray.WriteUTF(this.identity);
            DataByteArray.WriteList<byte>(this.team, byteArray, (b, t) => b.WriteByte(t));
        }
    }
}
